package com.myspring.service.impl;

import com.myspring.dao.UserDao;
import com.myspring.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ClassName: UserServiceImpl04
 * Package: com.myspring.service.impl
 * Description:
 *
 * @Author 刘英杰
 * @Create 2024/12/18 19:22
 * @Version 1.0
 */

@Service
public class UserServiceImpl04 implements UserService {

/*    @Resource 默认是字段名:userDaoImpl 作为Bean的id去装配,如果找到,装配成功
    private UserDao userDaoImpl;*/

    /*@Resource //首先将userDao作为Bean的id去装配,没有找到对应的Bean
                //再去按照类型去装配,匹配到两个Bean,导致异常
	private UserDao userDao;*/

    @Resource(name = "userDaoImpl02")
    //如果指定name属性值,将name的属性值作为Bean的id去装配,如果找到对应的Bean装配成功
    //如果找不到对应的Bean,装配失败
    private UserDao userDao;

    @Override
    public String toString() {
        return "UserServiceImpl04{" +
                "userDaoImpl=" + userDao +
                '}';
    }
}
